$('.unlogo').click(function(){
    location.href="../html/login.html";
})
$('.logo-box i').off();

//我的评价进行跳转
$('body').on('click','.mypinjia',function(){
    location.href="../html/我的评价.html";
})
if(localStorage.getItem('phone')){
    var d=localStorage.getItem('phone');
    console.log(d);
    $('.unlogo').html(d);
    $('.unlogo').off();
    $('.logo-box i').click(function(){
        location.href="../html/set.html";
    })
}
function lazy() {
    // 记录请求次数
    let page = 1;
    let flag = true
    // 页面初始，请求数据
    function ajx() {
        $.ajax({
            url: '../php/personal.php',
            type: 'get',
            dataType: 'json',
            data: {
                page
            },
            success: function (data) {
                // console.log(data.data)
                if (data.code == 1) {
                    let html = '';
                    data.data.forEach(item => {
                        html += `
                    <li>
                                <div class="lzload">
                                    <img src="${item.img}"
                                        alt="">
                                </div>
                                <div class="load-title">${item.des}</div>
                                <div class="pic">￥ ${item.pri}</div>

                            </li>
                    `
                    });
                    $('.good-list ul').append(html)
                    flag = true;
                } else {
                    // 数据加载完毕隐藏 此标签
                    $(".infinite-layer").hide();
                    $('.good-list ul').append('<li>没有更多数据...</li>');
                }
            },
            error: function () {
                console.log('连接失败')
            }

        })
    }

    ajx()

    // 添加滚动加载 请求数据
    $(window).scroll(function () {
        let scrollTop = $(window).scrollTop();
        // 窗口的高度
        let winHeight = $(window).height();
        // 页面高度
        let pageHeight = $("html").height();
        if (flag) {

            if (scrollTop + winHeight >= pageHeight - 5) {
                flag = false
                page++;
                ajx();

            }
        }

    })
};

lazy();

(function () {
    let num = 0;
    $('.bar-box').on('click', '.bar-right', function (e) {
        e.preventDefault();
        num++
        if (num % 2 == 0) {
            $(this).children(".fa-ellipsis-h").css({ opacity: '1' })
            $(this).children(".fa-times").css({ opacity: '0' })
            $('.drop-down').hide()
        } else {
            $(this).children(".fa-ellipsis-h").css({ opacity: '0' })
            $(this).children(".fa-times").css({ opacity: '1' })
            $('.drop-down').show()
        }
    })
})();


// 跳转到首页 分类
; (function () {
    $('.bar-box').on('click', '.bar-left ', function (e) {
        e.preventDefault();
            history.go(-1);
    });
    $('.menusWrap').on('click', '.flex-item:nth-of-type(1) ', function (e) {
        e.preventDefault();
        location.href = '../index.html'
    })
    $('.menusWrap').on('click', '.flex-item:nth-of-type(2) ', function (e) {
        e.preventDefault();
        location.href = 'classify.html'
    })
})()
